home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cc01.arc / ARCRIGHT.C < prev    next >
Text File  |  1986-03-14  |  4KB  |  251 lines

  1. /*
  2.     NetWare Local Archive Utility
  3.     V4.41    01/31/84    by Mark Hurst
  4.  
  5.     For use with NetWare V4.n systems
  6.  
  7.     Copyright (C) 1983, 1984 Novell, Inc.
  8. */
  9.  
  10. #include    "ctype.h"
  11. #include    "stdio.h"
  12.  
  13.  
  14. #define LOCALBIT    0x80
  15. #define    PERMNET        0x01
  16. #define    TEMPNET        0x02
  17. #define    NETBITS        0x03
  18.  
  19. #define    READBIT        0x01
  20. #define    WRITEBIT    0x02
  21. #define    OPENBIT        0x04
  22. #define    CREATEBIT    0x08
  23. #define    DELETEBIT    0x10
  24. #define    OWNEDBIT    0x20
  25. #define    SEARCHBIT    0x40
  26. #define    MODIFYBIT    0x80
  27.  
  28. /* NOTE: the Archive bit was 0x80 on ShareNet V3.12.  Has now changed: */
  29. #define BACKUPBIT    0x20
  30.  
  31.  
  32. #define        VARPATH        '^' - 'A'
  33.  
  34. #define        TRUE        1
  35. #define        FALSE        0
  36.  
  37. extern    FILE    *log;
  38. extern    int    source, target; /* low level I/O file numbers */
  39.  
  40.  
  41. char    *calloc(), *malloc();
  42.  
  43.  
  44. typedef struct dosfcb {
  45.     char    drive;
  46.     char    fname[8];
  47.     char    fext[3];
  48.     unsigned curblk;
  49.     unsigned recsize;
  50.     long    size;
  51.     unsigned date;
  52.     char    reserved[10];
  53.     char    relrec;
  54.     char    record[4];
  55. } FCB;
  56.  
  57. typedef    struct exdirfcb {
  58.     char    dummy;
  59.     char    exset;
  60.     char    res[5];
  61.     char    flags;
  62.     char    drive;
  63.     char    fname[8];
  64.     char    fext[3];
  65.     char    gap[17];
  66.     char    size[4];
  67. } ExDirFCB;
  68.  
  69. typedef struct exdosfcb {
  70.     char    dummy;
  71.     char    exset;
  72.     char    res[5];
  73.     char    flags;
  74.     char    drive;
  75.     char    fname[8];
  76.     char    fext[3];
  77.     unsigned curblk;
  78.     unsigned recsize;
  79.     long    size;
  80.     unsigned date;
  81.     char    reserved[10];
  82.     char    relrec;
  83.     char    record[4];
  84. } ExFCB;
  85.  
  86.  
  87. extern    int    listcount;
  88.  
  89. typedef    struct    liststruct {
  90.     struct liststruct *link;
  91.     char    name[12]; /* 1 too big for even allocation */
  92.     char    marked;
  93.     char    flags;
  94.     long    size;    /* size of file in bytes */
  95.     unsigned units;    /* size of file in allocation units */
  96. } LISTNODE;
  97.  
  98. #define     LISTSIZE    250
  99. extern    LISTNODE *list[LISTSIZE], *curnode;
  100.  
  101. extern    ExFCB    sourcefile;
  102. extern    ExFCB    destfile;
  103.  
  104.  
  105. int    imin();
  106. unsigned umin();
  107. long    lmin();
  108.  
  109.  
  110.  
  111. /*--------*/
  112.  
  113.  
  114. typedef struct getsubstruct {
  115.     int    length; 
  116.     char    function;
  117.     char    handle;
  118.     int    sequence; /* HIGH-LOW */
  119.     char    speclength;
  120. } GETSUB;
  121.  
  122. typedef struct retsubstruct {
  123.     int    length;
  124.     char    name[16];
  125.     char    createdate[2];
  126.     char    createtime[2];
  127.     long    creator;
  128.     char    rights;
  129.     char    padbyte;
  130.     int    dirnumber; /* HIGH-LOW */
  131. } RETSUB;
  132.  
  133.  
  134.  
  135.  
  136. int    DirRights (drive, rights)
  137.     char    drive, *rights;
  138. {
  139.     GETSUB    get;
  140.     RETSUB    ret;
  141.     char    type;
  142.     int    ccode;
  143.  
  144.     get.length = 5;
  145.     get.function = 2;
  146.     get.handle = GetHandle (drive, &type);
  147.     get.sequence = 0x100;    /* 1 in high-low order */
  148.     get.speclength = 0;
  149.  
  150.     ret.length = sizeof (RETSUB) - 2;
  151.     ccode = dirpath (&get, &ret);
  152.     *rights = ret.rights;
  153.     return (ccode);
  154. }
  155.  
  156. typedef struct gettrust {
  157.     int    length;
  158.     char    function;
  159.     char    handle;
  160.     char    setnumber;
  161.     char    speclength;
  162. } GETTRUST;
  163.  
  164. typedef struct rettrust {
  165.     int    length;
  166.     char    dirname [16];
  167.     char    createtime [4];
  168.     long    creator;
  169.     long    trustee [5];
  170.     char    mask [5];
  171. } RETTRUST;
  172.  
  173. ScanTrustees (drive, proc)
  174.     char    drive;
  175.     int    (*proc)();
  176. {
  177.     GETTRUST get;
  178.     RETTRUST ret;
  179.     char    type;
  180.     int    ccode, i;
  181.  
  182.     get.length = 4;
  183.     get.function = 12;
  184.     get.handle = GetHandle (drive, &type);
  185.     get.setnumber = 1;
  186.     get.speclength = 0;
  187.  
  188.     ret.length = sizeof (RETTRUST) - 2;
  189.     while (dirpath (&get, &ret) == 0) {
  190.         for (i = 0; i < 5; i++) {
  191.             if (ret.trustee [i] != (long) 0) 
  192.                 (*proc) (ret.trustee [i], ret.mask [i]);
  193.         }
  194.         get.setnumber ++;
  195.     }
  196. }
  197.  
  198. static    int    TCount;
  199.  
  200.  
  201. AddTrustFile ()
  202. {
  203.     int    TC;
  204.  
  205.     curnode = (LISTNODE *) calloc (1, sizeof (LISTNODE));
  206.     list [listcount ++] = curnode;
  207.     curnode->name[0] = 0x80;
  208.     curnode->marked = 0;
  209.     curnode->flags = 0;
  210.     curnode->size = 1000000L; /* dummy size anyway */
  211.     curnode->units = 0;
  212. }
  213.  
  214.  
  215. static    char    *tptr, *tcptr;
  216.  
  217.  
  218. TCopy (Trustee, Rights)
  219.     long    Trustee;
  220.     char    Rights;
  221. {
  222.     TCount ++;
  223.     movmem (&Trustee, tptr, 4);
  224.     tptr += 4;
  225.     *tptr ++ = Rights;
  226. }
  227.  
  228.  
  229. /* Return 0 if fail to write out trustee rights file, TRUE if OK */
  230. CopyTrustees (buffer)
  231.     char    *buffer;
  232. {
  233.     int    actual;
  234.     char    drights;
  235.  
  236.     TCount = 0;
  237.     tptr = buffer;
  238.     *tptr ++ = 0xFF; /* first byte indicates that stuff is saved in header*/
  239.     tcptr = tptr;
  240.     tptr += 2;
  241.  
  242.     if (DirRights (VARPATH, &drights)) *tptr ++ = 0xFF; /* default ALL */
  243.     else *tptr ++ = drights;
  244.  
  245.     ScanTrustees (VARPATH, TCopy);
  246.     /* COPY TRUSTEE COUNT */
  247.     tptr = &TCount;
  248.     *tcptr ++ = *tptr ++;
  249.     *tcptr = *tptr;
  250. }
  251.